{include file="public_head"}
{include file="public_menu"}
<div class="category_goods">
    <div class="content">
        <div class="main">
            <div class="left_main left">
                <div class="title">商品精选</div>
                <ul>
                    {volist name="guess_like" id="item" length="8"}
                    <li>
                        <a href="{:url('shopGoods/index',['good_id'=>$item.id])}" target="_blank">
                            <img src="/{$item.thumb_img}" class="pic">
                            <div class="price">￥{$item.price}</div>
                            <div class="name">{$item.title}</div>
                            <div class="num">已有<span>{$item.evaluate_number}</span>人评价</div>
                        </a>
                    </li>
                    {/volist}
                </ul>

            </div>
            <div class="right_main right" style="min-height: 2274px;">
                <div class="shop_left_list">
                    <ul class="left">
                        <li style="cursor:pointer;" {eq name=":input('order')" value="" }class="active"{/eq} onclick="set_sort('');">综合</li>
                        <li style="cursor:pointer;" {eq name=":input('order')" value="sale_number" }class="active"{/eq} onclick="set_sort('sale_number');">销量</li>
                        <li style="cursor:pointer;" {eq name=":input('order')" value="evaluate_number" }class="active"{/eq} onclick="set_sort('evaluate_number');">评论数</li>
                        <li style="cursor:pointer;" {eq name=":input('order')" value="create_time" }class="active"{/eq} onclick="set_sort('create_time');">新品</li>
                        <li style="cursor:pointer;" {eq name=":input('order')" value="price" }class="active"{/eq} onclick="set_sort('price');">价格</li>
                    </ul>
                    <!--<div class="input_price left">-->
                        <!--<input type="text" placeholder="￥" id="low_price" value="{:input('low')}">-->
                        <!--<label>-</label>-->
                        <!--<input type="text" placeholder="￥" id="high_price" value="{:input('high')}">-->
                    <!--</div>-->
                    <div class="right">共<span style="color:#E01222;">{$total}+</span>件商品</div>
                    <!--<div class="pages" style="margin-top: 100px;">{$data->render();}</div>-->
                </div>
                <ul class="list-item">
                    {volist name="data" id="vo"}
                    <li>
                        <a href="{:url('ShopGoods/index',['good_id'=>$vo.id])}" target="_blank">
                            <img src="/{$vo.thumb_img}" class="pic" onerror="this.src='__STATIC__/img/232.png'" style="height: 232px;">
                            <div class="price">￥{$vo.price}</div>
                            <div class="goods">{$vo.title|reStrLen=###,30}</div>
                            <div class="num">销量<span>{$vo.sale_number}</span></div>
                            <div class="shop-name">{$vo.shop.title|reStrLen=###,20}</div>
                            <div class="buy">立即购买</div>
                        </a>
                    </li>
                    {/volist}
                </ul>
            </div>
            <input type="hidden" id="type" value="{:input('type')}">
            <input type="hidden" id="order" value="{:input('order')}">
            <div class="pages" style="margin-top: 100px;">{$data->render();}</div>
        </div>
    </div>
</div>
<script>
    //    商品分类
    function set_cate(parameter) {
        var shop_id = $('#shop_id').val();
        var order = $('#order').val();
        $('#type').val(parameter);
        var url = "{:url('shop/goods_type/search_goods')}?type="+parameter+'&order='+order;
        window.location.href=url;
    }
    //商品排序
    function set_sort(parameter) {
        var shop_id = $('#shop_id').val();
        var parent_id = $('#type').val();
//    var title = $('#title').val();
        var title = "{:input('title')}";
        $('#order').val(parameter);
        var url = "{:url('shop/goods_type/search_goods')}?type="+parent_id+'&order='+parameter+"&title="+title;
        window.location.href=url;

    }
    // 关键字搜索
    function search() {
        var shop_id = $('#shop_id').val();
        var order = $('#order').val();
        var parent_id = $('#type').val();
        var title = "{:input('title')}";
        var url = "{:url('shop/goods_type/search_goods')}?type="+parent_id+'&order='+order+"&title="+title;
        window.location.href=url;

    }

    // 加入购物车
    function in_cart(id){
        var num = $('#num').val(),
                attr = $('#text_selected').text(),
                price = $('#default_price').val(),
                shop_id = $('#shop_id').val();
        $.ajax({
            url:"{:url('shop/shop_cart/default_cart')}",
            type:'post',
            dateType:'json',
            data:{'id':id,'attr':attr,'num':num,'price':price,'shop_id':shop_id},
            success:function (t) {
                if (t.code == 200){
                    layer.msg(t.message);
                }else if (t.code == 401){   //未登录
                    layer.msg(t.message);
                }else{
                    layer.msg(t.message);
                }
            }
        })
    }

</script>
{include file="public_foot"}